#ifndef _POLYGON2D_
#define _POLYGON2D_

#include <vector>
#include <algorithm>
#include <functional>
#include "vl/VLd.h"
#include "moremath.h"

using namespace std;
	
bool sortByX(Vec2d v1, Vec2d v2);

class Polygon2D{
	private:
		vector<Vec2d> mVertices;
		bool rightTurn(Vec2d v1, Vec2d v2, Vec2d v3);
		vector<Vec2d> sortVertices();
		double edgeDist(Vec2d p, Vec2d p0, Vec2d p1);
		int whichSide(Vec2d p, Vec2d p0, Vec2d p1);
	public:
		Polygon2D(vector<Vec2d> v);
		Vec2d getCentroid();
		vector<Vec2d> convexHull();
		vector<Vec2d> getVertices();
		void inflate(double scale);
		bool isInside(Vec2d p);
		double minEdgeDist(Vec2d p);
};

#endif

